package com.example.tellwin.mine.presenter;

import android.text.TextUtils;

import com.apkfuns.logutils.LogUtils;
import com.example.tellwin.MainApplication;
import com.example.tellwin.api.TwjfApi;
import com.example.tellwin.base.RxPresenter;
import com.example.tellwin.base.SimpleCallback;
import com.example.tellwin.home.bean.ContentBean;
import com.example.tellwin.mine.bean.WeChatPayBean;
import com.example.tellwin.mine.contract.CreditsExchangeContract;
import com.example.tellwin.mine.contract.RechargeContract;
import com.example.tellwin.utils.HttpUtils;
import com.example.tellwin.utils.ToastUtil;

import javax.inject.Inject;

import okhttp3.RequestBody;

/**
 * @author : LinZePeng
 * @date : 2020/12/1
 * @Describe ：
 **/
public class CreditsExchangePresenter extends RxPresenter<CreditsExchangeContract.View> implements CreditsExchangeContract.Presenter<CreditsExchangeContract.View> {

    private TwjfApi mApi;

    private int pages;
    private int pageNum;
    private final int pageSize = 10;
    private boolean isNotMore = true;

    @Inject
    public CreditsExchangePresenter(TwjfApi mApi) {
        this.mApi = mApi;
    }


    @Override
    public void getRegulation() {
        mApi.getRegulation(new SimpleCallback<ContentBean>(mView) {
            @Override
            public void onSuccess(ContentBean contentBean) {
                mView.regulationSuccess(contentBean.getIntegralSet());
            }

            @Override
            public void onFail(String msg) {

            }
        });
    }

    @Override
    public void creditsExchange(String integral) {
        RequestBody requestBody = HttpUtils.getRequestBody("integral" , integral+"");
        mApi.creditsExchange(requestBody , new SimpleCallback<ContentBean>(mView) {
            @Override
            public void onSuccess(ContentBean contentBean) {
                mView.creditsExchangeSuccess();
            }

            @Override
            public void onFail(String msg) {

            }
        });
    }
}
